const calculateEntropy = (probabilities) => {
  return probabilities.reduce((entropy, p) => {
    if (p > 0) {
      return entropy - p * Math.log2(p);
    }
    return entropy;
  }, 0);
};

module.exports = calculateEntropy;